home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Orlando_1993 / Devcon93.4 / CAMD / examples / trans / quickbevel.a < prev    next >
Encoding:
Text File  |  1993-01-01  |  3.9 KB  |  138 lines

  1. ******* ibox.lib/DrawBevel ************************************************
  2. *
  3. *   NAME
  4. *       DrawBevel -- Draws a bevel box, given an IBox and pen colors
  5. *
  6. *   SYNOPSIS
  7. *       DrawBevel( rp, box, ulpen, lrpen )
  8. *                  A1  A0   D0     D1
  9. *
  10. *       void __asm DrawBevel( register __a1 struct RastPort *,
  11. *                             register __a0 struct IBox *,
  12. *                             register __d0 WORD,
  13. *                             register __d1 WORD );
  14. *
  15. *   FUNCTION
  16. *       This function uses PolyDraw to render a bevel box. The horizontal
  17. *       thickness of the vertical lines is hard-coded at 2, and the vertical
  18. *       thickness of the horizontal lines is hard-coded at 1, for speed.
  19. *
  20. *   INPUTS
  21. *       rp          - RastPort to render to
  22. *       box         - box to render
  23. *       ulpen       - pen number to render upper-left lines in
  24. *       lrpen       - pen number to render lower-right lines in
  25. *
  26. *   EXAMPLE
  27. *
  28. *   NOTES
  29. *
  30. *   BUGS
  31. *
  32. *   SEE ALSO
  33. *       intuition/intuition.h, DrawThinBevel()
  34. *
  35. *****************************************************************************
  36. *    Written by Talin
  37. *
  38.             include        "intuition/intuition.i"
  39.  
  40.             SECTION        text,CODE
  41.  
  42.             xdef        _DrawBevel
  43.             xref        _LVOSetAPen,_LVOMove,_LVOPolyDraw,_GfxBase
  44.  
  45. _DrawBevel:
  46.             movem.l        d2-d7/a2/a6,-(sp)
  47.             move.l        a1,a2                    ; a2 <-- copy of rastport
  48.             move.l        d1,d2                    ; d2 <-- lrpen
  49.             move.l        _GfxBase,a6                ; a6 register
  50.  
  51.             moveq        #0,d4                    ; clear upper half of regs
  52.             moveq        #0,d5
  53.             moveq        #0,d6
  54.             moveq        #0,d7
  55.             movem.w        (a0),d4/d5/d6/d7        ; d4 <-- ibox_Left
  56.                                                 ; d5 <-- ibox_Top
  57.                                                 ; d6 <-- ibox_Width
  58.                                                 ; d7 <-- ibox_Height
  59.             add.w        d4,d6                    ; d6 <-- right
  60.             add.w        d5,d7                    ; d7 <-- bottom
  61.             subq.w        #1,d6                    ; d6 <-- left - 1
  62.             subq.w        #1,d7                    ; d7 <-- bottom - 1
  63.  
  64. ;---------- draw upper left part
  65.  
  66.             move.w        d5,-(sp)                ; coords[7] (y) = TOP
  67.             subq.w        #1,d6                    ; subtract 1 from RIGHT
  68.             move.w        d6,-(sp)                ; coords[6] (x) = RIGHT-1
  69.  
  70.             move.w        d5,-(sp)                ; coords[5] (y) = TOP
  71.             move.w        d4,-(sp)                ; coords[4] (x) = LEFT
  72.  
  73.             move.w        d7,-(sp)                ; coords[3] (y) = BOTTOM
  74.             move.w        d4,-(sp)                ; coords[2] (x) = LEFT
  75.  
  76.             subq.w        #1,d7                    ; subtract 1 from BOTTOM
  77.             move.w        d7,-(sp)                ; coords[1] (y) = BOTTOM -1
  78.             addq.w        #1,d4                    ; add 1 to LEFT
  79.             move.w        d4,-(sp)                ; coords[0] (x) = LEFT + 1
  80.  
  81. ;            move.l        d0,d0                    ; upper left pen color
  82.             move.l        a2,a1                    ; a1 <-- rp
  83.             jsr            _LVOSetAPen(a6)            ; set it
  84.  
  85.             move.l        d4,d0                    ; d0 <-- LEFT + 1
  86.             move.l        d5,d1                    ; d1 <-- TOP
  87.             addq.w        #1,d1                    ; d1 <-- TOP + 1
  88.             move.l        a2,a1                    ; a1 <-- rp
  89.             jsr            _LVOMove(a6)            ; Move to cursor coords
  90.  
  91.             moveq        #4,d0                    ; draw 4 points
  92.             move.l        sp,a0                    ; address of coords
  93.             move.l        a2,a1                    ; a1 <-- rp
  94.             jsr            _LVOPolyDraw(a6)        ; draw the line
  95.  
  96.             lea            16(sp),sp
  97.  
  98. ;---------- draw lower right part
  99.  
  100.             addq.w        #1,d7                    ; d7 <-- BOTTOM (fix from before)
  101.             addq.w        #1,d6                    ; d6 <-- RIGHT (fix from before)
  102.  
  103.             move.w        d7,-(sp)                ; coords[7] (y) = BOTTOM
  104.             move.w        d4,-(sp)                ; coords[6] (x) = LEFT + 1
  105.  
  106.             move.w        d7,-(sp)                ; coords[5] (y) = BOTTOM
  107.             move.w        d6,-(sp)                ; coords[4] (x) = RIGHT
  108.  
  109.             move.w        d5,-(sp)                ; coords[3] (y) = TOP
  110.             move.w        d6,-(sp)                ; coords[2] (x) = RIGHT
  111.  
  112.             addq.w        #1,d5                    ; add 1 to top
  113.             move.w        d5,-(sp)                ; coords[1] (y) = TOP + 1
  114.             subq.w        #1,d6                    ; subtract 1 from right
  115.             move.w        d6,-(sp)                ; coords[0] (x) = RIGHT - 1
  116.  
  117.             move.l        d2,d0                    ; lower right pen color
  118.             move.l        a2,a1                    ; a1 <-- rp
  119.             jsr            _LVOSetAPen(a6)            ; set it
  120.  
  121.             move.l        d6,d0                    ; d0 <-- RIGHT - 1
  122.             move.l        d7,d1                    ; d1 <-- BOTTOM
  123.             subq.w        #1,d1                    ; d1 <-- BOTTOM - 1
  124.             move.l        a2,a1                    ; a1 <-- rp
  125.             jsr            _LVOMove(a6)            ; Move to cursor coords
  126.  
  127.             moveq        #4,d0                    ; draw 4 points
  128.             move.l        sp,a0                    ; address of coords
  129.             move.l        a2,a1                    ; a1 <-- rp
  130.             jsr            _LVOPolyDraw(a6)        ; draw the line
  131.  
  132.             lea            16(sp),sp
  133.  
  134.             movem.l        (sp)+,d2-d7/a2/a6
  135.             rts
  136.  
  137.             end
  138.